import 'bgcContentSave.dart';

class BgcContentBo {
  final int? id;
  final String? aid;
  final String? title;
  final String? content;
  final String? richContent;
  final List<String>? images;
  final String? videos;
  final String? thumbnail;
  final int? taskRecordId;
  final List<TaskTagBo>? taskTagBoList;
  final String? status; // 修改为String类型
  final bool? detached; // 添加缺失的字段

  BgcContentBo({
    this.id,
    this.aid,
    this.title,
    this.content,
    this.richContent,
    this.images,
    this.videos,
    this.thumbnail,
    this.taskRecordId,
    this.taskTagBoList,
    this.status,
    this.detached,
  });

  factory BgcContentBo.fromJson(Map<String, dynamic> json) {
    return BgcContentBo(
      id: json['id'] as int?,
      aid: json['aid'] as String?,
      title: json['title'] as String?,
      content: json['content'] as String?,
      richContent: json['richContent'] as String?,
      images: json['images'] != null ? List<String>.from(json['images']) : null,
      videos: json['videos'] as String?,
      thumbnail: json['thumbnail'] as String?,
      taskRecordId: json['taskRecordId'] as int?,
      taskTagBoList: json['taskTagBoList'] != null
          ? List<TaskTagBo>.from(
              json['taskTagBoList'].map((x) => TaskTagBo.fromJson(x)))
          : null,
      status: json['status'] as String?, // 修改为String类型
      detached: json['detached'] as bool?,
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'aid': aid,
      'title': title,
      'content': content,
      'richContent': richContent,
      'images': images,
      'videos': videos,
      'thumbnail': thumbnail,
      'taskRecordId': taskRecordId,
      'taskTagBoList': taskTagBoList?.map((tag) => tag.toJson()).toList(),
      'status': status,
      'detached': detached,
    };
  }
}
